import { _decorator, Component, Node } from 'cc';
import { PropItem } from '../PropItem';
import { BaseGame } from '../../../games/BaseGame';
import { _game, _tip } from '../../../Main';
import { MergeDish } from '../../../games/MergeDish';
import { GameState } from '../../../managers/GameManager';
const { ccclass, property } = _decorator;

@ccclass('MDUncover')
export class MDUncover extends PropItem {

    showName: string = '透视'

    shortDesc: string = '揭开所有盖子'

    fullDesc: string = '将全部食物的盖子揭开，显示出下方的食物'

    cost: number = 150

    useable(): boolean {
        let game: BaseGame = _game.game
        if (!(game instanceof MergeDish)) {
            return false
        }
        if (!game.isInGameState(GameState.Gaming)) {
            return false
        }
        if (game.isTrial()) {

            return false
        }
        if (game.getCoveredDishes().length <= 0) {
            _tip.tip('当前没有可以揭开的盖子')
            return false
        }
        return true
    }

    use(): void {
        let game: BaseGame = _game.game
        if (!(game instanceof MergeDish)) {
            return
        }
        game.uncover()
    }
}


